package Test;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTabbedPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class game extends JFrame {

	private JPanel contentPane;
	private JTabbedPane tabbedPane;
	private JPanel panel;
	private JPanel panel_1;
	private JPanel panel_2;
	private JPanel panel_3;
	private JScrollPane scrollPane;
	private JButton btnNewButton;
	private JButton btnNewButton_1;
	private JLabel lblNewLabel;
	private JTextField st;

	int a = (int) (Math.random() * 1000) + 1;
	int count = 0;

	int su;
	String user = "";

	private JTextArea result;
	private JScrollPane scrollPane_1;
	private JTextArea result1;
	private JButton btnNewButton_2;
	private JButton btnNewButton_3;
	private JButton btnNewButton_4;
	private JButton btnNewButton_5;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					game frame = new game();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public game() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		contentPane.add(getTabbedPane());
	}

	private JTabbedPane getTabbedPane() {
		if (tabbedPane == null) {
			tabbedPane = new JTabbedPane(JTabbedPane.TOP);
			tabbedPane.setBounds(31, 10, 362, 242);
			tabbedPane.addTab("스무고개", null, getPanel_1(), null);
			tabbedPane.addTab("가위바위보", null, getPanel_2(), null);
			tabbedPane.addTab("묵찌빠", null, getPanel_3(), null);
			tabbedPane.addTab("New tab", null, getPanel(), null);
		}
		return tabbedPane;
	}

	private JPanel getPanel() {
		if (panel == null) {
			panel = new JPanel();
		}
		return panel;
	}

	private JPanel getPanel_1() {
		if (panel_1 == null) {
			panel_1 = new JPanel();
			panel_1.setLayout(null);
			panel_1.add(getScrollPane_1());
			panel_1.add(getBtnNewButton());
			panel_1.add(getBtnNewButton_1());
			panel_1.add(getLblNewLabel());
			panel_1.add(getSt());
		}
		return panel_1;
	}

	private JPanel getPanel_2() {
		if (panel_2 == null) {
			panel_2 = new JPanel();
			panel_2.setLayout(null);
			panel_2.add(getScrollPane_1_1());
			panel_2.add(getBtnNewButton_2());
			panel_2.add(getBtnNewButton_3());
			panel_2.add(getBtnNewButton_4());
			panel_2.add(getBtnNewButton_5());
		}
		return panel_2;
	}

	private JPanel getPanel_3() {
		if (panel_3 == null) {
			panel_3 = new JPanel();
			panel_3.setLayout(null);
		}
		return panel_3;
	}

	private JScrollPane getScrollPane_1() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 10, 333, 115);
			scrollPane.setViewportView(getResult());
		}
		return scrollPane;
	}

	private JButton getBtnNewButton() {
		if (btnNewButton == null) {
			btnNewButton = new JButton("입력");
			btnNewButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					String b = st.getText();
					int i = Integer.parseInt(b);
					result.append("" + i);

					if (a == i) {
						result.append("\n이기셨네요 대단합니다 존경 스럽습니다 우러러볼게요 존경합니다");
						result.append("\n");
						count++;
						result.append("\n실행한 횟수:" + count);

					} else if (a > i) {
						result.append("\n업업업 사람이 배짱이 있어야지");
						result.append("\n");
						count++;

					} else if (a < i) {
						result.append("\n간땡이가 배밖으로 튀어 나오셨네요 작작 배팅하세요");
						result.append("\n");
						count++;
					}

				}
			});
			btnNewButton.setBounds(12, 180, 155, 23);
		}
		return btnNewButton;
	}

	private JButton getBtnNewButton_1() {
		if (btnNewButton_1 == null) {
			btnNewButton_1 = new JButton("리셋");
			btnNewButton_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					result.setText("");
					count = 0;
				}
			});
			btnNewButton_1.setBounds(179, 180, 155, 23);
		}
		return btnNewButton_1;
	}

	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("입력창");
			lblNewLabel.setBounds(12, 144, 57, 15);
		}
		return lblNewLabel;
	}

	private JTextField getSt() {
		if (st == null) {
			st = new JTextField();
			st.setBounds(81, 141, 69, 21);
			st.setColumns(10);
		}
		return st;
	}

	private JTextArea getResult() {
		if (result == null) {
			result = new JTextArea();
		}
		return result;
	}

	private JScrollPane getScrollPane_1_1() {
		if (scrollPane_1 == null) {
			scrollPane_1 = new JScrollPane();
			scrollPane_1.setBounds(12, 10, 333, 89);
			scrollPane_1.setViewportView(getResult1());
		}
		return scrollPane_1;
	}

	private JTextArea getResult1() {
		if (result1 == null) {
			result1 = new JTextArea();
		}
		return result1;
	}

	private JButton getBtnNewButton_2() {
		if (btnNewButton_2 == null) {
			btnNewButton_2 = new JButton("가위");
			btnNewButton_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					String com;

					su = (int) (Math.random() * 3);

					switch (su) {
					case 0:
						com = "가위";
						break;
					case 1:
						com = "바위";
						break;
					default:
						com = "보";
						break;
					}
					user = "가위";
					if (com.equals("가위")) {
						result1.append("비겼습니다 황송하지만 다시한번 수고해주세요~(com:" + com
								+ ")\n");
					} else if (com.equals("바위")) {
						result1.append("컄컄컄 이겼다 발로 하냐 드럽게 못하네(com:" + com
								+ ")\n");
					} else {
						result1.append("운이 조금 아주 조금 있군 날 이기다니(com:" + com
								+ ")\n");
					}
				}
			});
			btnNewButton_2.setBounds(12, 135, 97, 23);
		}
		return btnNewButton_2;
	}

	private JButton getBtnNewButton_3() {
		if (btnNewButton_3 == null) {
			btnNewButton_3 = new JButton("바위");
			btnNewButton_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					String com;
					su = (int) (Math.random() * 3);

					switch (su) {
					case 0:
						com = "가위";
						break;
					case 1:
						com = "바위";
						break;
					default:
						com = "보";
						break;
					}
					user = "바위";
					if (com.equals("가위")) {
						result1.append("운이 조금 아주 조금 있군 날 이기다니(com:" + com
								+ ")\n");
					} else if (com.equals("바위")) {
						result1.append("비겼습니다 황송하지만 다시한번 수고해주세요~(com:" + com
								+ ")\n");

					} else {
						result1.equals("컄컄컄 이겼다 발로 하냐 드럽게 못하네(com:" + com
								+ ")\n");

					}
				}
			});
			btnNewButton_3.setBounds(121, 135, 97, 23);
		}
		return btnNewButton_3;
	}

	private JButton getBtnNewButton_4() {
		if (btnNewButton_4 == null) {
			btnNewButton_4 = new JButton("보자기");
			btnNewButton_4.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					String com;
					su = (int) (Math.random() * 3);

					switch (su) {
					case 0:
						com = "가위";
						break;
					case 1:
						com = "바위";
						break;
					default:
						com = "보";
						break;
					}
					user = "보";
					if (com.equals("가위")) {
						result1.append("컄컄컄 이겼다 발로 하냐 드럽게 못하네(com:" + com
								+ ")\n");
					} else if (com.equals("바위")) {
						result1.append("운이 조금 아주 조금 있군 날 이기다니(com:" + com
								+ ")\n");
					} else
						result1.append("비겼습니다 황송하지만 다시한번 수고해주세요~(com:" + com
								+ ")\n");

				}
			});
			btnNewButton_4.setBounds(230, 135, 97, 23);
		}
		return btnNewButton_4;
	}

	private JButton getBtnNewButton_5() {
		if (btnNewButton_5 == null) {
			btnNewButton_5 = new JButton("초기화");
			btnNewButton_5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					result1.setText("");
				}
			});
			btnNewButton_5.setBounds(12, 168, 315, 23);
		}
		return btnNewButton_5;
	}
}
